package com.oneraku.service.domain;

import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.oneraku.service.domain.BaseEntity;
import com.oneraku.service.dto.WorkOrderCommentInfo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 工单评论
 * </p>
 *
 * @author renhui <337375464@qq.com>
 * @since 2020-02-25
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class WorkOrderComment extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 工单id
     */
    private String workOrderId;

    /**
     * 评论内容
     */
    private String txt = "";

    /**
     * 附件
     */
    private String attach="";

    /**
     * 评论人id
     */
    private String uid;

    /**
     * 管理员id
     */
    private String sid;

    /**
     * 类型：sys,usr
     */
    private String type;
    /**
     * 是否已读
     */
    @TableField(value = "`read`")
    private Boolean read;

    /**
     * 管理员是否已读
     */
    private Boolean sread;
    /**
     * 星
     */
    @TableField(exist = false)
    private Integer star = 0;

    /**
     * 是否已解决
     */
    @TableField(exist = false)
    private Boolean resovled = Boolean.FALSE;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @TableField(exist = false,value = "count")
    private Integer count;


    public WorkOrderCommentInfo toInfo(String uName,String uAvatar){
        WorkOrderCommentInfo workOrderCommentInfo = new WorkOrderCommentInfo();
        workOrderCommentInfo.setCommentId(getId());
        workOrderCommentInfo.setUid(getUid());
        workOrderCommentInfo.setUAvatar(uAvatar);
        workOrderCommentInfo.setUTxt(getTxt());
        workOrderCommentInfo.setUName(uName);
        workOrderCommentInfo.setType(getType());
        return workOrderCommentInfo;
    }
}
